<?php
// get params from view
//echo 'hieu'; exit();
if(isset($this->seatCountYouWant)) {
	$seatCountYouWant = $this->seatCountYouWant;
	$selectedSeatNumbers = $this->selectedSeatNumbers;	
	$fare = $this->fare;
		
?>
<div class="TBB_content">
<p>Mời quý khách xem lại các vé đã đặt. Nếu quý khách đồng ý thì nhập mã xác nhận và hoàn tất đặt vé.</p>
</div>
<hr></hr>
<table class="rounded-corner" cellpadding="0" cellspacing="0">
	<thead>
		<tr>
			<th scope="col" class="rounded-left">Từ</th>
			<th scope="col">Đến</th>
			<th scope="col">Giờ khởi hành</th>
			<th scope="col">Xuất phát</th>
			<th scope="col">Giá vé</th>
			<th scope="col" class="rounded-right" >Số ghế</th>
		</tr>
	</thead>
	<tfoot>
    	<tr>
        	<td colspan="5" class="rounded-foot-left">&nbsp;</td>
        	<td class="rounded-foot-right">&nbsp;</td>
        </tr>
    </tfoot>
	<tbody>
		<tr>
			<td><?php echo $this->from_city; ?></td>
			<td><?php echo $this->to_city; ?></td>
			<td><?php echo $this->departure_time; ?></td>
			<td><?php echo $this->boarding_point; ?></td>
			<td><?php echo $this->fare; ?></td>
			<td><?php					
				$selectedSeatCount = count($selectedSeatNumbers);				
				$spelling = array(1 => 'Một', 2 => 'Hai', 3 => 'Ba', 4 => 'Bốn', 5 => 'Năm');

				echo $spelling[$seatCountYouWant] . ' ghế. Gồm: ' . '<br>';
				for($i = 0; $i < $selectedSeatCount; ++$i) {
					echo '+ Ghế số ' . $selectedSeatNumbers[$i];
					if($i < $selectedSeatCount - 1 && $selectedSeatCount > 1) {
						echo '<br>';
					}
				}
				
				$remainingSeatCount = $seatCountYouWant - $selectedSeatCount;				
				if($selectedSeatCount > 0 && $remainingSeatCount > 0) {
					echo '<br>';
				}				
				if($remainingSeatCount > 0) {					
					echo '+ ' . $spelling[$remainingSeatCount] . ' ghế không cố định';
				}
			?></td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td style="border-top-style: solid; border-top-width: thin;">
			<?php
			$fareOfAll = $seatCountYouWant * $fare;
			echo 'Tổng tiền: ';			
			?></td>
			<td style="border-top-style: solid; border-top-width: thin;">
			<?php echo $fareOfAll;?>
			</td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td>
			<?php
			$discount = 0;
			echo 'Giảm giá: ';			
			?></td>
			<td><?php echo $discount;?></td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td>
			<?php
			echo 'Tổng thanh toán: ';			
			?></td>
			<td><?php echo $fareOfAll - $discount;?></td>
		</tr>
	</tbody>
</table>
<div class="span-20"><?php echo $this->bookingFinishForm;?></div>
<?php } else { ?>
<h2>What are you doing? Don't be a hero please!</h2>
<?php echo $this->homepage(); ?>
<?php } ?>